/*
 * 文章内容管理
 */
const express = require("express");
const articlsHandle = require("../router_handle/articls");
// 导入数据合法性验证的中间件
const expressJoi = require("@escook/express-joi");
// 数据校验
const {
    add_articl_schema,
    update_articl_schema,
    id_articl_schema,
} = require("../schema/articls");

const router = express.Router();

// 添加文章
router.post("/addAticl", expressJoi(add_articl_schema), articlsHandle.addAticl);
// 根据id修改文章
router.post(
    "/updateAticl",
    expressJoi(update_articl_schema),
    articlsHandle.updateAticl
);
// 根据id获取文章信息
router.get(
    "/getArticlByid",
    expressJoi(id_articl_schema),
    articlsHandle.getArticlByid
);
// 根据id删除文章信息
router.get(
    "/deleteArticlById",
    expressJoi(id_articl_schema),
    articlsHandle.deleteArticlById
);
// 获取所有文章信息
router.get("/getArticles", articlsHandle.getArticls);

module.exports = router;